import "package:ct_pa_majordomo/utils/request.dart";
import "package:dio/dio.dart";

class EntranceGuardApi {
  Future<Map> getEntranceGuardList(queryParameters) async {
    Response response = await request.get(
      "device/face_lock/list",
      queryParameters: queryParameters,
    );
    return response.data ?? {};
  }

  /* 新增门禁 */
  Future<Map> saveEntranceGuard(queryParameters) async {
    Response response = await request.post(
      "device/face_lock",
      data: queryParameters,
    );
    return response.data ?? {};
  }

  /* 编辑门禁 */
  Future<Map> editEntranceGuard(queryParameters) async {
    Response response = await request.put(
      "device/face_lock",
      data: queryParameters,
    );
    return response.data ?? {};
  }

  Future<Map> getFaceLockInfo(int faceLockId) async {
    Response response = await request.get(
      "device/face_lock/$faceLockId",
    );
    return response.data ?? {};
  }

  /* 删除门禁 */
  Future<Map> removeEntranceGuard(faceLockIds) async {
    Response response = await request.delete(
      "device/face_lock/$faceLockIds",
    );
    return response.data ?? {};
  }

  // 获取关联入住人信息
  Future<Map> getRenters(int faceLockId) async {
    Response response = await request.get(
      "device/face_lock/get-renders/$faceLockId",
    );
    return response.data ?? {};
  }

  // 远程开门
  Future<Map> unlock(int faceLockId) async {
    Response response = await request.post(
      "device/face_lock/open-door/$faceLockId",
    );
    return response.data ?? {};
  }

  // 下发人脸
  Future<Map> syncPerson(int faceLockId) async {
    Response response = await request.post(
      "device/face_lock/sync-person/$faceLockId",
    );
    return response.data ?? {};
  }

  // 已绑定门禁房间列表
  Future<Map> boundRooms(int faceLockId) async {
    Response response = await request.get(
      "device/face_lock/bound-rooms/$faceLockId",
    );
    return response.data ?? {};
  }
  

  // 未绑定门禁房间列表
  Future<Map> unboundRooms(int faceLockId) async {
    Response response = await request.get(
      "device/face_lock/unbound-rooms/$faceLockId",
    );
    return response.data ?? {};
  }

  // 解绑门禁与房间的关联
  Future<Map> unbindRoom(int faceLockId, int roomId) async {
    Response response = await request.delete(
      "device/face_lock/unbind-room/$faceLockId/$roomId",
    );
    return response.data ?? {};
  }

  // 批量解绑门禁与房间的关联
  Future<Map> unbindRooms(int faceLockId, String roomIds) async {
    Response response = await request.delete(
      "device/face_lock/batch-unbind-room",
      data: {
        "faceLockIds": faceLockId,
        "roomIds": roomIds,
      },
    );
    return response.data ?? {};
  }


  // 批量绑定房间到门禁
  Future<Map> bindRooms(queryParameters) async {
    Response response = await request.post(
      "device/face_lock/bind-room/${queryParameters["faceLockId"]}",
      queryParameters: queryParameters,
    );
    return response.data ?? {};
  }

  // 获取房间未绑定的门禁列表
  Future<Map> unbindList(int roomId) async {
    Response response = await request.get(
      "device/face_lock/unbind-list/$roomId",
    );
    return response.data ?? {};
  }
}

EntranceGuardApi entranceGuardApi = EntranceGuardApi();